package com.songcha.module_home.ui.activity.more_new_book

import android.view.View
import android.widget.ImageView
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.listener.OnItemClickListener
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.scwang.smart.refresh.layout.SmartRefreshLayout
import com.songcha.library_base.mvvm.base.BaseRefreshLoadMoreMvvmActivity
import com.songcha.library_business.interfaces.IOnBookClickListener
import com.songcha.library_business.ui.adapter.BookListAdapter
import com.songcha.library_business.util.BusinessJumpUtil
import com.songcha.module_home.R
import com.songcha.module_home.databinding.HomeActivityMoreNewbookShelveBinding

class MoreNewBookShelveActivity:BaseRefreshLoadMoreMvvmActivity<MoreNewBookShelveViewModel,HomeActivityMoreNewbookShelveBinding>(),IOnBookClickListener {
    var mAdapter:BookListAdapter?=null

    override fun getLayoutId(): Int {
        return R.layout.home_activity_more_newbook_shelve
    }

    override fun isNeedShowLoad(): Boolean {
        return true
    }

    override fun isCalculateHearBarHeight(): Boolean {
        return true
    }

    override fun isImmerseStatusBar(): Boolean {
        return true
    }

    override fun onGetData() {
        viewModel.getNewBookShelveList()
    }

    override fun onGetLoadMoreData() {
        viewModel.getNewBookShelveList()
    }

    override fun initListData() {
        databinding.homeMoreNewbookRcv.apply{
            layoutManager = LinearLayoutManager(context)
            mAdapter = BookListAdapter(viewModel.rlst.value!!,this@MoreNewBookShelveActivity)
            adapter = mAdapter
        }
    }

    override fun getRefreshLayout(): SmartRefreshLayout {
        return databinding.homeMoreNewbookSrl
    }

    override fun getListAdapter(): RecyclerView.Adapter<BaseViewHolder>? {
        return mAdapter
    }

    override fun onBookClick(bookId: String,img: ImageView) {
        BusinessJumpUtil.toBookDetail(bookId)
    }

}